import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from fastapi import FastAPI
from starlette.middleware.cors import CORSMiddleware

from backend.routers.auth_router import router as auth_router
from backend.routers.detection_router import router as detection_router
from backend.routers.admin_router import router as admin_router
# from backend.routers.analysis_router import router as analysis_router

app = FastAPI(title="眼部疾病检测系统后端")

# 跨域配置
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# 挂载路由
app.include_router(auth_router)
app.include_router(detection_router)
app.include_router(admin_router)
# app.include_router(analysis_router)

@app.get("/")
def root():
    return {"message": "API服务已启动"}

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="127.0.0.1", port=8080)